<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
<!-- 客户管理 -->
<div class="admin-section">
  <h3>客户管理</h3>
  <button onclick="showForm('customer')">添加客户</button>

  <!-- 搜索功能 -->
  <input type="text" id="customerSearch" placeholder="搜索客户...">
  <select id="searchType">
    <option value="exact">精确查询</option>
    <option value="fuzzy">模糊查询</option>
    <option value="range">范围查询</option>
  </select>

  <!-- 结果表格 -->
  <table id="customerTable">
    <thead>
      <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>身份证</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody></tbody>
  </table>
</div>

<script>
// AJAX获取客户数据
function loadCustomers() {
  fetch('/admin/customer')
    .then(res => res.json())
    .then(data => {
      const tbody = document.querySelector('#customerTable tbody');
      tbody.innerHTML = '';

      data.forEach(customer => {
        const row = `
          <tr>
            <td>${customer.customerID}</td>
            <td>${customer.customerName}</td>
            <td>${customer.PID}</td>
            <td>
              <button onclick="editCustomer(${customer.customerID})">编辑</button>
              <button onclick="deleteCustomer(${customer.customerID})">删除</button>
            </td>
          </tr>
        `;
        tbody.innerHTML += row;
      });
    });
}
</script>